package com.c.ctgproject.adapter.guang

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.c.ctgproject.databinding.ItemCheckFlowListBinding
import com.c.ctgproject.entity.guang.CheckDetailEntity
import com.c.ctgproject.entity.guang.MaterialOutCheckDetailEntity
import com.c.ctgproject.utils.handlerNull

class OutCheckFlowAdapter(private val context: Context, private val mList: List<MaterialOutCheckDetailEntity.DataBean.HistoriesBean>) : RecyclerView.Adapter<OutCheckFlowAdapter.MyViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
        val view = ItemCheckFlowListBinding.inflate(LayoutInflater.from(context), parent, false)
        return MyViewHolder(view)
    }

    override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
        val data = mList[position]
        if (data.flowType==11){
            holder.mTopTV.text="出库申请"
            holder.mBottomTV.text = data.createPersonName.handlerNull()
        }else{
            holder.mTopTV.text="出库审批"
            holder.mBottomTV.text = data.createPersonName.handlerNull()+"(${if (data.status==1)"通过" else "不通过"})"
        }

        holder.mTimeTV.text = data.createTime.handlerNull()

        //处理竖线
        holder.mLineView.visibility = if (position == mList.size - 1) View.GONE else View.VISIBLE
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    inner class MyViewHolder(view: ItemCheckFlowListBinding) : RecyclerView.ViewHolder(view.root) {
        val mImageView = view.mImageView
        val mTopTV = view.mTopTV
        val mBottomTV = view.mBottomTV
        val mTimeTV = view.mTimeTV
        val mLineView = view.mLineView
    }
}

